import Vue from 'vue'
import VueI18n from 'vue-i18n'
import {getCookie,delCookie,addCookie} from "../api/addCookie.js"
//import zn from './config/zn.js'
//import en from './config/en.js'

		Vue.use(VueI18n);
		// 先判断是不是注册页和下载页根据这两个切换语言
  if (window.location.hash == '#/register' || window.location.hash == '#/download'){
		
			if (navigator.language.indexOf('zh') == '-1'){
				// 没有包含indexOf('zh')等于-1是英文
				var lan = 'en'
			}else{
				var lan = 'zh'
			}
		}else{
			var ua = navigator.userAgent.toLowerCase();
			if (/iphone|ipad|ipod/.test(ua)) {
				if ((typeof jsObj) != "undefined") {
					var lan = jsObj.getAppLanguage()

				} else {
					var lan = 'zh'
				}
			} else if (/android/.test(ua)) {
				if ((typeof jsObj) != "undefined") {
					var lan = jsObj.getAppLanguage()
				} else {
					var lan = 'zh'
				}
			} else {
				var lan = 'zh'

			}
		}
  
	
addCookie('lan',lan)

const i18n = new VueI18n({
  locale: lan,//这个配置的是默认的语言包
//locale: 'zh',//这个配置的是默认的语言包
  messages: {
    'zh': require('./config/zn.js'),   // 中文语言包
    'en': require('./config/en.js')    // 英文语言包
  },
});
export default i18n